package com.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

//这和Ribbon Provider中的applicationname一致
@FeignClient(value = "sayHello")
interface FeignClientRibbonTool
{
	@RequestMapping(method = RequestMethod.GET, value = "/sayHello/{username}")
	String sayHelloAsRibbon(@PathVariable("username") String username);
}

 
@RestController
public class ControllerForFeignRibbon {
		
	@Autowired
	private FeignClientRibbonTool tool;
	
	@RequestMapping(value = "/callHelloAsRibbon/{username}", method = RequestMethod.GET)
	public String callHelloAsRibbon(@PathVariable("username") String username) {
		return tool.sayHelloAsRibbon(username);
	}
	
	
	
	
}
